<?php
setup_get_parameters();
if(!empty($maped_routes) and !empty($maped_routes[camelcasify(get_current_model())])) {
    $current_route = $maped_routes[camelcasify(get_current_model())];
    $controller = $current_route["model"] . 'Controller';
    $action = $current_route["action"];
}
else {
    $controller = (get_current_model() == null) ? DEFAULT_CONTROLLER . "Controller" : camelcasify(get_current_model()) . "Controller";
    $action = get_current_action();
}

$vars = get_class_vars($controller);

if($vars["visible_from_url"] === true) {
  try {
    $controller = new $controller($action);
  }
  catch(Exception $e) {
    echo $e->getMessage();
  }
}
else {
  render_404_error();
}

if(is_script()) {
    render_content();
}
?>